/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FormHorasAula.java
 *
 * Created on 26/01/2012, 16:38:00
 */
package Formularios;

import Atributos.*;
import Metodos.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Andre
 */
public class FormHorasAula extends javax.swing.JFrame {
    DefaultTableModel tmHA = new DefaultTableModel(null, new String[]{"Serie", "Turma", "Professor", "Disciplina", "Horas Aula"});
    List<HorasAula> HA;
    ListSelectionModel lsmHA;
    private List<Curso> listaC;
    HorasAulaMet hamet=new HorasAulaMet();
    List <Disciplina> listaD;
    Curso curso=new Curso();
 ProfDiscMet profdiscmet=new ProfDiscMet();
 DisciplinaMet discmet=new DisciplinaMet();
 Disciplina disciplina=new Disciplina();
ProfessorMet profmet=new ProfessorMet();
 Professor professor=new Professor();
 List <Professor> listaP;
 CursoMet cursomet=new CursoMet();
    private List<Serie> listaS;
 Serie serie= new Serie();
 SerieMet seriemet=new SerieMet();
   MinimizaTela tela= new MinimizaTela(); 
   DefaultTableModel tmHA2 = new DefaultTableModel(null, new String[]{"Professor", "Disciplina", "Horas Aula"});
 
 ListSelectionModel lsmHA2;
 
 String escolha;    static int id;  static String pesquisa;
    public FormHorasAula() {
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Windows".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FormHorasAula.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        try {
            tela.Minimiza(1);
        } catch (SQLException ex) {
            Logger.getLogger(FormHorasAula.class.getName()).log(Level.SEVERE, null, ex);
        }
        initComponents();
        BufferedImage image=null;
        File imageFile=new File(".\\src\\Imagens\\logo3.png");
        try {
            image=ImageIO.read(imageFile);
            
        } catch (IOException ex) {
        }
        this.setIconImage(image);
        
//        BufferedImage image=new BufferedImage(10,10,BufferedImage.TYPE_INT_ARGB);
//        setIconImage(image);
        DesabilitaADDALT();
        DesabilitaVISDEL();
        DesabilitaVis();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        buttonGroup3 = new javax.swing.ButtonGroup();
        jDesktopPane1 = new javax.swing.JDesktopPane();
        jPanel1 = new javax.swing.JPanel();
        jSeparator1 = new javax.swing.JSeparator();
        jRB_adicionar = new javax.swing.JRadioButton();
        jRB_deletar = new javax.swing.JRadioButton();
        jRB_visualizar = new javax.swing.JRadioButton();
        jTF_totalHA = new javax.swing.JTextField();
        jl_Totalha = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTTabela_HA2 = new javax.swing.JTable();
        jl_descricao1 = new javax.swing.JLabel();
        jCB_descricao1 = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jl_serie1 = new javax.swing.JLabel();
        jRB_1 = new javax.swing.JRadioButton();
        jRB_2 = new javax.swing.JRadioButton();
        jRB_3 = new javax.swing.JRadioButton();
        jCB_ano = new javax.swing.JComboBox();
        jCB_descricao = new javax.swing.JComboBox();
        jl_ano = new javax.swing.JLabel();
        jl_descricao = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jl_nome = new javax.swing.JLabel();
        CB_Professor = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jCB_disciplina = new javax.swing.JComboBox();
        jl_disciplina = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jl_horaaula = new javax.swing.JLabel();
        jTF_horaaula = new javax.swing.JTextField();
        jL_editar = new javax.swing.JLabel();
        jL_adicionar = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTTable_hora_aula = new javax.swing.JTable();
        RB_Professor = new javax.swing.JRadioButton();
        RB_Materia = new javax.swing.JRadioButton();
        jl_eixo = new javax.swing.JLabel();
        jl_hora_aulas = new javax.swing.JTextField();
        jl_eixo1 = new javax.swing.JLabel();
        jl_eixo2 = new javax.swing.JLabel();
        jl_eixo3 = new javax.swing.JLabel();
        jl_eixo4 = new javax.swing.JLabel();
        jlpesquisa = new javax.swing.JLabel();
        JTF_Pesquisar2 = new javax.swing.JTextField();
        jl_serie = new javax.swing.JTextField();
        jl_turma = new javax.swing.JTextField();
        jl_materia = new javax.swing.JTextField();
        jl_prof = new javax.swing.JTextField();
        jL_deletar = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Horas Aula");
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(0, 0, 0));
        jPanel1.setLayout(null);

        jSeparator1.setBackground(new java.awt.Color(255, 153, 0));
        jSeparator1.setForeground(new java.awt.Color(0, 0, 0));
        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jPanel1.add(jSeparator1);
        jSeparator1.setBounds(170, 20, 11, 600);

        jRB_adicionar.setBackground(new java.awt.Color(0, 0, 0));
        buttonGroup1.add(jRB_adicionar);
        jRB_adicionar.setFont(new java.awt.Font("D3 Euronism italic", 0, 18)); // NOI18N
        jRB_adicionar.setForeground(new java.awt.Color(255, 102, 0));
        jRB_adicionar.setText("<html>Adicionar<br><br>Alterar");
        jRB_adicionar.setFocusPainted(false);
        jRB_adicionar.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jRB_adicionarItemStateChanged(evt);
            }
        });
        jPanel1.add(jRB_adicionar);
        jRB_adicionar.setBounds(10, 130, 150, 90);

        jRB_deletar.setBackground(new java.awt.Color(0, 0, 0));
        buttonGroup1.add(jRB_deletar);
        jRB_deletar.setFont(new java.awt.Font("D3 Euronism italic", 0, 18)); // NOI18N
        jRB_deletar.setForeground(new java.awt.Color(255, 102, 0));
        jRB_deletar.setText("Deletar");
        jRB_deletar.setFocusPainted(false);
        jRB_deletar.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jRB_deletarItemStateChanged(evt);
            }
        });
        jPanel1.add(jRB_deletar);
        jRB_deletar.setBounds(10, 490, 150, 90);

        jRB_visualizar.setBackground(new java.awt.Color(0, 0, 0));
        buttonGroup1.add(jRB_visualizar);
        jRB_visualizar.setFont(new java.awt.Font("D3 Euronism italic", 0, 18)); // NOI18N
        jRB_visualizar.setForeground(new java.awt.Color(255, 102, 0));
        jRB_visualizar.setText("Visualizar");
        jRB_visualizar.setFocusPainted(false);
        jRB_visualizar.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jRB_visualizarItemStateChanged(evt);
            }
        });
        jPanel1.add(jRB_visualizar);
        jRB_visualizar.setBounds(10, 310, 150, 90);

        jTF_totalHA.setBackground(new java.awt.Color(0, 0, 0));
        jTF_totalHA.setEditable(false);
        jTF_totalHA.setFont(new java.awt.Font("Comic Sans MS", 1, 18)); // NOI18N
        jTF_totalHA.setForeground(new java.awt.Color(255, 255, 255));
        jTF_totalHA.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jTF_totalHA.setBorder(javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, new java.awt.Color(255, 255, 255)));
        jTF_totalHA.setCaretColor(new java.awt.Color(255, 255, 255));
        jPanel1.add(jTF_totalHA);
        jTF_totalHA.setBounds(560, 590, 70, 40);

        jl_Totalha.setBackground(new java.awt.Color(0, 0, 0));
        jl_Totalha.setFont(new java.awt.Font("D3 Euronism italic", 1, 18)); // NOI18N
        jl_Totalha.setForeground(new java.awt.Color(255, 255, 255));
        jl_Totalha.setText("Total de Horas Aulas:");
        jPanel1.add(jl_Totalha);
        jl_Totalha.setBounds(210, 600, 330, 30);

        jScrollPane2.setBackground(new java.awt.Color(0, 0, 0));
        jScrollPane2.setBorder(javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, new java.awt.Color(0, 0, 0)));
        jScrollPane2.setForeground(new java.awt.Color(51, 204, 0));
        jScrollPane2.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        jTTabela_HA2.setBackground(new java.awt.Color(0, 0, 0));
        jTTabela_HA2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTTabela_HA2.setForeground(new java.awt.Color(255, 255, 255));
        jTTabela_HA2.setModel(tmHA2);
        jTTabela_HA2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jTTabela_HA2.setGridColor(new java.awt.Color(255, 255, 255));
        jTTabela_HA2.setInheritsPopupMenu(true);
        jTTabela_HA2.setSelectionBackground(new java.awt.Color(255, 255, 255));
        jTTabela_HA2.setSelectionForeground(new java.awt.Color(0, 0, 0));
        jTTabela_HA2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        lsmHA2 = jTTabela_HA2.getSelectionModel();
        lsmHA2.addListSelectionListener(new ListSelectionListener(){
            public void valueChanged(ListSelectionEvent e){
                if(! e.getValueIsAdjusting()){
                    JTTabelaLinhaSelecionada2(jTTabela_HA2);
                }
            }
        }
    );
    jScrollPane2.setViewportView(jTTabela_HA2);

    jPanel1.add(jScrollPane2);
    jScrollPane2.setBounds(200, 150, 890, 420);

    jl_descricao1.setBackground(new java.awt.Color(0, 0, 0));
    jl_descricao1.setFont(new java.awt.Font("D3 Euronism italic", 1, 14)); // NOI18N
    jl_descricao1.setForeground(new java.awt.Color(255, 255, 255));
    jl_descricao1.setText("Turma:");
    jPanel1.add(jl_descricao1);
    jl_descricao1.setBounds(580, 70, 118, 17);

    jCB_descricao1.setBackground(new java.awt.Color(0, 0, 0));
    jCB_descricao1.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
    jPanel1.add(jCB_descricao1);
    jCB_descricao1.setBounds(700, 70, 60, 27);

    jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/OKlay1.jpg"))); // NOI18N
    jLabel4.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    jLabel4.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jLabel4MouseClicked(evt);
        }
    });
    jPanel1.add(jLabel4);
    jLabel4.setBounds(870, 50, 70, 60);

    jl_serie1.setBackground(new java.awt.Color(0, 0, 0));
    jl_serie1.setFont(new java.awt.Font("D3 Euronism italic", 1, 14)); // NOI18N
    jl_serie1.setForeground(new java.awt.Color(255, 255, 255));
    jl_serie1.setText("Serie:");
    jPanel1.add(jl_serie1);
    jl_serie1.setBounds(240, 40, 79, 17);

    jRB_1.setBackground(new java.awt.Color(0, 0, 0));
    buttonGroup3.add(jRB_1);
    jRB_1.setFont(new java.awt.Font("D3 Euronism italic", 0, 24)); // NOI18N
    jRB_1.setForeground(new java.awt.Color(255, 102, 0));
    jRB_1.setText("1");
    jRB_1.setFocusPainted(false);
    jRB_1.addItemListener(new java.awt.event.ItemListener() {
        public void itemStateChanged(java.awt.event.ItemEvent evt) {
            jRB_1ItemStateChanged(evt);
        }
    });
    jPanel1.add(jRB_1);
    jRB_1.setBounds(240, 70, 50, 37);

    jRB_2.setBackground(new java.awt.Color(0, 0, 0));
    buttonGroup3.add(jRB_2);
    jRB_2.setFont(new java.awt.Font("D3 Euronism italic", 0, 24)); // NOI18N
    jRB_2.setForeground(new java.awt.Color(255, 102, 0));
    jRB_2.setText("2");
    jRB_2.setFocusPainted(false);
    jRB_2.addItemListener(new java.awt.event.ItemListener() {
        public void itemStateChanged(java.awt.event.ItemEvent evt) {
            jRB_2ItemStateChanged(evt);
        }
    });
    jPanel1.add(jRB_2);
    jRB_2.setBounds(330, 70, 50, 37);

    jRB_3.setBackground(new java.awt.Color(0, 0, 0));
    buttonGroup3.add(jRB_3);
    jRB_3.setFont(new java.awt.Font("D3 Euronism italic", 0, 24)); // NOI18N
    jRB_3.setForeground(new java.awt.Color(255, 102, 0));
    jRB_3.setText("3");
    jRB_3.setFocusPainted(false);
    jRB_3.addItemListener(new java.awt.event.ItemListener() {
        public void itemStateChanged(java.awt.event.ItemEvent evt) {
            jRB_3ItemStateChanged(evt);
        }
    });
    jPanel1.add(jRB_3);
    jRB_3.setBounds(430, 70, 50, 40);

    jCB_ano.setBackground(new java.awt.Color(0, 0, 0));
    jCB_ano.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
    jCB_ano.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jCB_anoActionPerformed(evt);
        }
    });
    jPanel1.add(jCB_ano);
    jCB_ano.setBounds(460, 130, 50, 27);

    jCB_descricao.setBackground(new java.awt.Color(0, 0, 0));
    jCB_descricao.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
    jPanel1.add(jCB_descricao);
    jCB_descricao.setBounds(650, 130, 60, 27);

    jl_ano.setBackground(new java.awt.Color(0, 0, 0));
    jl_ano.setFont(new java.awt.Font("D3 Euronism italic", 1, 14)); // NOI18N
    jl_ano.setForeground(new java.awt.Color(255, 255, 255));
    jl_ano.setText("Ano:");
    jPanel1.add(jl_ano);
    jl_ano.setBounds(390, 140, 42, 17);

    jl_descricao.setBackground(new java.awt.Color(0, 0, 0));
    jl_descricao.setFont(new java.awt.Font("D3 Euronism italic", 1, 14)); // NOI18N
    jl_descricao.setForeground(new java.awt.Color(255, 255, 255));
    jl_descricao.setText("Turma:");
    jPanel1.add(jl_descricao);
    jl_descricao.setBounds(560, 140, 64, 17);

    jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/selecionar(fig).jpg"))); // NOI18N
    jLabel1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    jLabel1.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jLabel1MouseClicked(evt);
        }
    });
    jPanel1.add(jLabel1);
    jLabel1.setBounds(900, 250, 202, 46);

    jl_nome.setBackground(new java.awt.Color(0, 0, 0));
    jl_nome.setFont(new java.awt.Font("D3 Euronism italic", 1, 14)); // NOI18N
    jl_nome.setForeground(new java.awt.Color(255, 255, 255));
    jl_nome.setText("Professor: ");
    jPanel1.add(jl_nome);
    jl_nome.setBounds(310, 270, 124, 17);

    CB_Professor.setBackground(new java.awt.Color(0, 0, 0));
    CB_Professor.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
    jPanel1.add(CB_Professor);
    CB_Professor.setBounds(470, 260, 260, 27);

    jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/selecionar(fig).jpg"))); // NOI18N
    jLabel2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    jLabel2.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jLabel2MouseClicked(evt);
        }
    });
    jPanel1.add(jLabel2);
    jLabel2.setBounds(900, 120, 202, 46);

    jCB_disciplina.setBackground(new java.awt.Color(0, 0, 0));
    jCB_disciplina.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
    jPanel1.add(jCB_disciplina);
    jCB_disciplina.setBounds(320, 380, 570, 27);

    jl_disciplina.setBackground(new java.awt.Color(0, 0, 0));
    jl_disciplina.setFont(new java.awt.Font("D3 Euronism italic", 1, 14)); // NOI18N
    jl_disciplina.setForeground(new java.awt.Color(255, 255, 255));
    jl_disciplina.setText("Disciplina(s):");
    jPanel1.add(jl_disciplina);
    jl_disciplina.setBounds(180, 390, 121, 17);

    jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/buscar(fig).jpg"))); // NOI18N
    jLabel3.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    jLabel3.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jLabel3MouseClicked(evt);
        }
    });
    jPanel1.add(jLabel3);
    jLabel3.setBounds(900, 370, 202, 46);

    jl_horaaula.setBackground(new java.awt.Color(0, 0, 0));
    jl_horaaula.setFont(new java.awt.Font("D3 Euronism italic", 1, 14)); // NOI18N
    jl_horaaula.setForeground(new java.awt.Color(255, 255, 255));
    jl_horaaula.setText("Horas Aula:");
    jPanel1.add(jl_horaaula);
    jl_horaaula.setBounds(310, 520, 125, 17);

    jTF_horaaula.setBackground(new java.awt.Color(0, 0, 0));
    jTF_horaaula.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
    jTF_horaaula.setForeground(new java.awt.Color(255, 255, 255));
    jTF_horaaula.setHorizontalAlignment(javax.swing.JTextField.CENTER);
    jTF_horaaula.setBorder(javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, new java.awt.Color(255, 255, 255)));
    jTF_horaaula.setCaretColor(new java.awt.Color(255, 255, 255));
    jPanel1.add(jTF_horaaula);
    jTF_horaaula.setBounds(470, 510, 70, 30);

    jL_editar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/butoneditar.jpg"))); // NOI18N
    jL_editar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    jL_editar.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jL_editarMouseClicked(evt);
        }
    });
    jPanel1.add(jL_editar);
    jL_editar.setBounds(710, 510, 187, 44);

    jL_adicionar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/butonadicionar.jpg"))); // NOI18N
    jL_adicionar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    jL_adicionar.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jL_adicionarMouseClicked(evt);
        }
    });
    jPanel1.add(jL_adicionar);
    jL_adicionar.setBounds(710, 510, 187, 44);

    jScrollPane1.setBackground(new java.awt.Color(0, 0, 0));
    jScrollPane1.setBorder(javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, new java.awt.Color(0, 0, 0)));
    jScrollPane1.setForeground(new java.awt.Color(51, 204, 0));
    jScrollPane1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

    jTTable_hora_aula.setBackground(new java.awt.Color(0, 0, 0));
    jTTable_hora_aula.setForeground(new java.awt.Color(255, 255, 255));
    jTTable_hora_aula.setModel(tmHA
    );
    jTTable_hora_aula.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    jTTable_hora_aula.setGridColor(new java.awt.Color(255, 255, 255));
    jTTable_hora_aula.setInheritsPopupMenu(true);
    jTTable_hora_aula.setSelectionBackground(new java.awt.Color(255, 255, 255));
    jTTable_hora_aula.setSelectionForeground(new java.awt.Color(0, 0, 0));
    jTTable_hora_aula.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    lsmHA = jTTable_hora_aula.getSelectionModel();
    lsmHA.addListSelectionListener(new ListSelectionListener(){
        public void valueChanged(ListSelectionEvent e){
            if(! e.getValueIsAdjusting()){
                JTTabelaLinhaSelecionada(jTTable_hora_aula);
            }
        }
    }
    );
    jScrollPane1.setViewportView(jTTable_hora_aula);

    jPanel1.add(jScrollPane1);
    jScrollPane1.setBounds(210, 120, 860, 230);

    RB_Professor.setBackground(new java.awt.Color(0, 0, 0));
    buttonGroup2.add(RB_Professor);
    RB_Professor.setFont(new java.awt.Font("D3 Euronism italic", 0, 18)); // NOI18N
    RB_Professor.setForeground(new java.awt.Color(255, 102, 0));
    RB_Professor.setText("Professor");
    RB_Professor.setFocusPainted(false);
    RB_Professor.addItemListener(new java.awt.event.ItemListener() {
        public void itemStateChanged(java.awt.event.ItemEvent evt) {
            RB_ProfessorItemStateChanged(evt);
        }
    });
    jPanel1.add(RB_Professor);
    RB_Professor.setBounds(880, 10, 152, 30);

    RB_Materia.setBackground(new java.awt.Color(0, 0, 0));
    buttonGroup2.add(RB_Materia);
    RB_Materia.setFont(new java.awt.Font("D3 Euronism italic", 0, 18)); // NOI18N
    RB_Materia.setForeground(new java.awt.Color(255, 102, 0));
    RB_Materia.setText("Disciplina");
    RB_Materia.setFocusPainted(false);
    RB_Materia.addItemListener(new java.awt.event.ItemListener() {
        public void itemStateChanged(java.awt.event.ItemEvent evt) {
            RB_MateriaItemStateChanged(evt);
        }
    });
    jPanel1.add(RB_Materia);
    RB_Materia.setBounds(880, 50, 136, 30);

    jl_eixo.setBackground(new java.awt.Color(0, 0, 0));
    jl_eixo.setFont(new java.awt.Font("D3 Euronism italic", 1, 14)); // NOI18N
    jl_eixo.setForeground(new java.awt.Color(255, 255, 255));
    jl_eixo.setText("Serie:");
    jPanel1.add(jl_eixo);
    jl_eixo.setBounds(260, 510, 58, 17);

    jl_hora_aulas.setBackground(new java.awt.Color(0, 0, 0));
    jl_hora_aulas.setEditable(false);
    jl_hora_aulas.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
    jl_hora_aulas.setForeground(new java.awt.Color(255, 255, 255));
    jl_hora_aulas.setHorizontalAlignment(javax.swing.JTextField.CENTER);
    jl_hora_aulas.setBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 2, 2, new java.awt.Color(255, 255, 255)));
    jl_hora_aulas.setCaretColor(new java.awt.Color(255, 255, 255));
    jPanel1.add(jl_hora_aulas);
    jl_hora_aulas.setBounds(830, 500, 50, 23);

    jl_eixo1.setBackground(new java.awt.Color(0, 0, 0));
    jl_eixo1.setFont(new java.awt.Font("D3 Euronism italic", 1, 14)); // NOI18N
    jl_eixo1.setForeground(new java.awt.Color(255, 255, 255));
    jl_eixo1.setText("Turma");
    jPanel1.add(jl_eixo1);
    jl_eixo1.setBounds(450, 510, 60, 17);

    jl_eixo2.setBackground(new java.awt.Color(0, 0, 0));
    jl_eixo2.setFont(new java.awt.Font("D3 Euronism italic", 1, 14)); // NOI18N
    jl_eixo2.setForeground(new java.awt.Color(255, 255, 255));
    jl_eixo2.setText("Professor:");
    jPanel1.add(jl_eixo2);
    jl_eixo2.setBounds(260, 400, 112, 17);

    jl_eixo3.setBackground(new java.awt.Color(0, 0, 0));
    jl_eixo3.setFont(new java.awt.Font("D3 Euronism italic", 1, 14)); // NOI18N
    jl_eixo3.setForeground(new java.awt.Color(255, 255, 255));
    jl_eixo3.setText("Disciplina:");
    jPanel1.add(jl_eixo3);
    jl_eixo3.setBounds(260, 460, 100, 17);

    jl_eixo4.setBackground(new java.awt.Color(0, 0, 0));
    jl_eixo4.setFont(new java.awt.Font("D3 Euronism italic", 1, 14)); // NOI18N
    jl_eixo4.setForeground(new java.awt.Color(255, 255, 255));
    jl_eixo4.setText("Horas Aula:");
    jPanel1.add(jl_eixo4);
    jl_eixo4.setBounds(690, 510, 125, 17);

    jlpesquisa.setBackground(new java.awt.Color(0, 0, 0));
    jlpesquisa.setFont(new java.awt.Font("D3 Euronism italic", 1, 14)); // NOI18N
    jlpesquisa.setForeground(new java.awt.Color(255, 255, 255));
    jlpesquisa.setText("Pesquisar Por ->");
    jPanel1.add(jlpesquisa);
    jlpesquisa.setBounds(670, 40, 182, 17);

    JTF_Pesquisar2.setBackground(new java.awt.Color(0, 0, 0));
    JTF_Pesquisar2.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
    JTF_Pesquisar2.setForeground(new java.awt.Color(255, 255, 255));
    JTF_Pesquisar2.setHorizontalAlignment(javax.swing.JTextField.CENTER);
    JTF_Pesquisar2.setBorder(javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, new java.awt.Color(255, 255, 255)));
    JTF_Pesquisar2.setCaretColor(new java.awt.Color(255, 255, 255));
    JTF_Pesquisar2.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyReleased(java.awt.event.KeyEvent evt) {
            JTF_Pesquisar2KeyReleased(evt);
        }
    });
    jPanel1.add(JTF_Pesquisar2);
    JTF_Pesquisar2.setBounds(230, 40, 400, 25);

    jl_serie.setBackground(new java.awt.Color(0, 0, 0));
    jl_serie.setEditable(false);
    jl_serie.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
    jl_serie.setForeground(new java.awt.Color(255, 255, 255));
    jl_serie.setHorizontalAlignment(javax.swing.JTextField.CENTER);
    jl_serie.setBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 2, 2, new java.awt.Color(255, 255, 255)));
    jl_serie.setCaretColor(new java.awt.Color(255, 255, 255));
    jPanel1.add(jl_serie);
    jl_serie.setBounds(330, 500, 60, 23);

    jl_turma.setBackground(new java.awt.Color(0, 0, 0));
    jl_turma.setEditable(false);
    jl_turma.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
    jl_turma.setForeground(new java.awt.Color(255, 255, 255));
    jl_turma.setHorizontalAlignment(javax.swing.JTextField.CENTER);
    jl_turma.setBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 2, 2, new java.awt.Color(255, 255, 255)));
    jl_turma.setCaretColor(new java.awt.Color(255, 255, 255));
    jPanel1.add(jl_turma);
    jl_turma.setBounds(530, 500, 70, 23);

    jl_materia.setBackground(new java.awt.Color(0, 0, 0));
    jl_materia.setEditable(false);
    jl_materia.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
    jl_materia.setForeground(new java.awt.Color(255, 255, 255));
    jl_materia.setHorizontalAlignment(javax.swing.JTextField.CENTER);
    jl_materia.setBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 2, 2, new java.awt.Color(255, 255, 255)));
    jl_materia.setCaretColor(new java.awt.Color(255, 255, 255));
    jPanel1.add(jl_materia);
    jl_materia.setBounds(380, 450, 690, 23);

    jl_prof.setBackground(new java.awt.Color(0, 0, 0));
    jl_prof.setEditable(false);
    jl_prof.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
    jl_prof.setForeground(new java.awt.Color(255, 255, 255));
    jl_prof.setHorizontalAlignment(javax.swing.JTextField.CENTER);
    jl_prof.setBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 2, 2, new java.awt.Color(255, 255, 255)));
    jl_prof.setCaretColor(new java.awt.Color(255, 255, 255));
    jPanel1.add(jl_prof);
    jl_prof.setBounds(400, 390, 410, 23);

    jL_deletar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/butondeletar.jpg"))); // NOI18N
    jL_deletar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    jL_deletar.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jL_deletarMouseClicked(evt);
        }
    });
    jPanel1.add(jL_deletar);
    jL_deletar.setBounds(550, 590, 187, 44);

    jPanel1.setBounds(0, 0, 1150, 710);
    jDesktopPane1.add(jPanel1, javax.swing.JLayeredPane.DEFAULT_LAYER);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1112, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addComponent(jDesktopPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 727, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGap(0, 0, Short.MAX_VALUE))
    );

    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width-1128)/2, (screenSize.height-681)/2, 1128, 681);
    }// </editor-fold>//GEN-END:initComponents

    private void jRB_adicionarItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jRB_adicionarItemStateChanged
if(jRB_adicionar.isSelected()){
        if(Verificasehaseie()){   
     DesabilitaVISDEL();
     DesabilitaVis();
       escolha=jRB_adicionar.getText();
       ChamaEscolha(escolha);
        try {
            InicializaDadosADDALT();
        } catch (SQLException ex) {
            Logger.getLogger(FormHorasAula.class.getName()).log(Level.SEVERE, null, ex);
        }
 }else{
     JOptionPane.showMessageDialog(null, "Não ha series adicionadas!");
 }
}
    }//GEN-LAST:event_jRB_adicionarItemStateChanged

    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
        try {
            tela.Minimiza(0);
        } catch (SQLException ex) {
            Logger.getLogger(FormHorasAula.class.getName()).log(Level.SEVERE, null, ex);
        }
      
       java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new ChamaLayout().setVisible(true);
            }
        }); 
    }//GEN-LAST:event_formWindowClosed

    private void jCB_anoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCB_anoActionPerformed
       String nome= jCB_ano.getSelectedItem().toString();
        try {
            listaS=seriemet.Buscar(nome);
        } catch (SQLException ex) {
            Logger.getLogger(FormHorasAula.class.getName()).log(Level.SEVERE, null, ex);
        }
        String[] descrição = new String[listaS.size()];
        for(int i = 0;listaS.size()>i;i++){
        serie = listaS.get(i);
        descrição[i] = serie.getTurma(); 
        }
        jCB_descricao.setModel(new javax.swing.DefaultComboBoxModel(descrição));
    }//GEN-LAST:event_jCB_anoActionPerformed

    private void jLabel2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel2MouseClicked
      
         
          serie.setNome(jCB_ano.getSelectedItem().toString());
         
          serie.setTurma(jCB_descricao.getSelectedItem().toString());
          
       
        try {
            listaP= profmet.BuscarProfPorTurma(serie);
        } catch (SQLException ex) {
            Logger.getLogger(FormHorasAula.class.getName()).log(Level.SEVERE, null, ex);
        }
        if(listaP.isEmpty()){
             JOptionPane.showMessageDialog(null, "Não ha professores cadastrados nesta turma!");
        }else{
        jLabel1.setVisible(true);
        jl_nome.setVisible(true);
        CB_Professor.setVisible(true);
        String[] prof = new String[listaP.size()];
        for(int i = 0;listaP.size()>i;i++){
        professor = listaP.get(i);
       prof[i] = professor.getNome(); 
        }
        CB_Professor.setModel(new javax.swing.DefaultComboBoxModel(prof)); 
        }
       
          
       
    }//GEN-LAST:event_jLabel2MouseClicked

    private void jLabel1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel1MouseClicked
       professor.setNome(CB_Professor.getSelectedItem().toString());
        try {
            listaD=profdiscmet.BuscarDiasciplinasdoProfessor(professor);
        } catch (SQLException ex) {
            Logger.getLogger(FormHorasAula.class.getName()).log(Level.SEVERE, null, ex);
        }
       if(listaD.isEmpty()){
            JOptionPane.showMessageDialog(null, "Não ha disciplinas cadastradas com este professor!");
       }else{
           jLabel3.setVisible(true);
           jCB_disciplina.setVisible(true);
           jl_disciplina.setVisible(true);
            String[] disc = new String[listaD.size()];
        for(int i = 0;listaD.size()>i;i++){
        disciplina = listaD.get(i);
       disc[i] = disciplina.getNome(); 
        }
        jCB_disciplina.setModel(new javax.swing.DefaultComboBoxModel(disc)); 
        
       }
        
    }//GEN-LAST:event_jLabel1MouseClicked

    private void jLabel3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel3MouseClicked
       serie.setNome(jCB_ano.getSelectedItem().toString());
      serie.setTurma(jCB_descricao.getSelectedItem().toString());
      professor.setNome(CB_Professor.getSelectedItem().toString());
      disciplina.setNome(jCB_disciplina.getSelectedItem().toString());
      
      int HAs=hamet.BuscarHoraAulaPelaDisciplina(serie,professor,disciplina);
      
      if(HAs==0){
          jl_horaaula.setVisible(true);
          jTF_horaaula.setVisible(true);
          jL_adicionar.setVisible(true);
          jL_editar.setVisible(false);
          jTF_horaaula.setText("");
      }else{
          jl_horaaula.setVisible(true);
          jL_adicionar.setVisible(false);
          jTF_horaaula.setVisible(true);
          jL_editar.setVisible(true);
          jTF_horaaula.setText(String.valueOf(HAs));
      }
    }//GEN-LAST:event_jLabel3MouseClicked

    private void jL_editarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jL_editarMouseClicked
       int HAs=Integer.parseInt(jTF_horaaula.getText());
      serie.setNome(jCB_ano.getSelectedItem().toString());
      serie.setTurma(jCB_descricao.getSelectedItem().toString());
      professor.setNome(CB_Professor.getSelectedItem().toString());
      disciplina.setNome(jCB_disciplina.getSelectedItem().toString());
      
      int id_serie=seriemet.BuscarID(serie);
      int id_prof=profmet.BuscaId(professor);
      int id_disc=discmet.BuscaIDDisciplina(disciplina);
        try {
            hamet.EditaHA(id_serie,id_prof,id_disc,HAs);
        } catch (SQLException ex) {
            Logger.getLogger(FormHorasAula.class.getName()).log(Level.SEVERE, null, ex);
        }
        JOptionPane.showMessageDialog(null, "Editado com sucesso!");
    }//GEN-LAST:event_jL_editarMouseClicked

    private void jL_adicionarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jL_adicionarMouseClicked
      if(!"".equals(jTF_horaaula.getText())){
        int HAs=Integer.parseInt(jTF_horaaula.getText());
      serie.setNome(jCB_ano.getSelectedItem().toString());
      serie.setTurma(jCB_descricao.getSelectedItem().toString());
      professor.setNome(CB_Professor.getSelectedItem().toString());
      disciplina.setNome(jCB_disciplina.getSelectedItem().toString());
      int id_serie=seriemet.BuscarID(serie);
       
      int id_prof=profmet.BuscaId(professor);
       
      int id_disc=discmet.BuscaIDDisciplina(disciplina);
            try {
                hamet.Adicionar(id_serie,id_prof,id_disc,HAs);
            } catch (SQLException ex) {
                Logger.getLogger(FormHorasAula.class.getName()).log(Level.SEVERE, null, ex);
            }
            JOptionPane.showMessageDialog(null, "Adicionado com sucesso!");
      }else{
          JOptionPane.showMessageDialog(null, "Campo vazio!");
      
      }
    }//GEN-LAST:event_jL_adicionarMouseClicked

    private void jRB_deletarItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jRB_deletarItemStateChanged
if(jRB_deletar.isSelected()){
        if(VerificaseHA()){     
         DesabilitaADDALT();  
         DesabilitaVis();
         escolha=jRB_deletar.getText();
       ChamaEscolha(escolha);
            try {
                BuscaDadosTabela();
            } catch (SQLException ex) {
                Logger.getLogger(FormHorasAula.class.getName()).log(Level.SEVERE, null, ex);
            }
} else{
     DesabilitaADDALT(); 
     JOptionPane.showMessageDialog(null, "Não ha dados cadastrados!");
}      
}     
    }//GEN-LAST:event_jRB_deletarItemStateChanged

    private void JTF_Pesquisar2KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_JTF_Pesquisar2KeyReleased
     if("Professor".equals(pesquisa)){        try {
            BuscaDadosTabela();
        } catch (SQLException ex) {
            Logger.getLogger(FormHorasAula.class.getName()).log(Level.SEVERE, null, ex);
        }
}if("Disciplina".equals(pesquisa)){
            try {
                PesquisarPorMateria();
            } catch (SQLException ex) {
                Logger.getLogger(FormHorasAula.class.getName()).log(Level.SEVERE, null, ex);
            }
}
    }//GEN-LAST:event_JTF_Pesquisar2KeyReleased

    private void RB_ProfessorItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_RB_ProfessorItemStateChanged
      pesquisa=RB_Professor.getText();
    }//GEN-LAST:event_RB_ProfessorItemStateChanged

    private void RB_MateriaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_RB_MateriaItemStateChanged
       pesquisa=RB_Materia.getText();
    }//GEN-LAST:event_RB_MateriaItemStateChanged

    private void jL_deletarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jL_deletarMouseClicked
    if( !"".equals(jl_serie.getText())){
        int resp = JOptionPane.showConfirmDialog(this, "Deseja realmente excluir este dado?",
                "Confirmação", JOptionPane.YES_NO_OPTION);

        if (resp == JOptionPane.YES_NO_OPTION) {
        
        HorasAulaMet dao=new HorasAulaMet();
            try {
                dao.Excluir(id);
            } catch (SQLException ex) {
                Logger.getLogger(FormHorasAula.class.getName()).log(Level.SEVERE, null, ex);
            }
            try {
                BuscaDadosTabela();
            } catch (SQLException ex) {
                Logger.getLogger(FormHorasAula.class.getName()).log(Level.SEVERE, null, ex);
            }
        
  limpaDados();
    JTF_Pesquisar2.setText("");
    JOptionPane.showMessageDialog(null, "Excluído com sucesso!");
        }
    }else{
        JOptionPane.showMessageDialog(null, "Nada selecionado.");
    }
    }//GEN-LAST:event_jL_deletarMouseClicked

    private void jRB_visualizarItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jRB_visualizarItemStateChanged
if(jRB_visualizar.isSelected()){
        if(VerificaseHA()){     
         DesabilitaADDALT();  
         DesabilitaVISDEL();
         escolha=jRB_visualizar.getText();
       ChamaEscolha(escolha);
            
} else{
     DesabilitaADDALT(); 
     JOptionPane.showMessageDialog(null, "Não ha dados cadastrados!");
}      
}            
    }//GEN-LAST:event_jRB_visualizarItemStateChanged

    private void jRB_1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jRB_1ItemStateChanged
        if(jRB_1.isSelected()){
        String nome= jRB_1.getText();
        listaC=cursomet.BuscarDescricaoporSerie(nome);
        if(!listaC.isEmpty()){
        String[] descrição = new String[listaC.size()];
        for(int i = 0;listaC.size()>i;i++){
        curso = listaC.get(i);
        descrição[i] = curso.getDescrição(); 
        }
        jCB_descricao1.setModel(new javax.swing.DefaultComboBoxModel(descrição));
        }
        }
    }//GEN-LAST:event_jRB_1ItemStateChanged

    private void jRB_2ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jRB_2ItemStateChanged
         if(jRB_2.isSelected()){
        String nome= jRB_2.getText();
        listaC=cursomet.BuscarDescricaoporSerie(nome);
        if(!listaC.isEmpty()){
        String[] descrição = new String[listaC.size()];
        for(int i = 0;listaC.size()>i;i++){
        curso = listaC.get(i);
        descrição[i] = curso.getDescrição(); 
        }
        jCB_descricao1.setModel(new javax.swing.DefaultComboBoxModel(descrição));
        }
        }
    }//GEN-LAST:event_jRB_2ItemStateChanged

    private void jRB_3ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jRB_3ItemStateChanged
        if(jRB_3.isSelected()){
        String nome= jRB_3.getText();
        listaC=cursomet.BuscarDescricaoporSerie(nome);
        if(!listaC.isEmpty()){
        String[] descrição = new String[listaC.size()];
        for(int i = 0;listaC.size()>i;i++){
        curso = listaC.get(i);
        descrição[i] = curso.getDescrição(); 
        }
        jCB_descricao1.setModel(new javax.swing.DefaultComboBoxModel(descrição));
        }
        }
    }//GEN-LAST:event_jRB_3ItemStateChanged

    private void jLabel4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel4MouseClicked
        if(buttonGroup3.getSelection()==null || jCB_descricao1.getModel().getSelectedItem()==null){
            JOptionPane.showMessageDialog(rootPane, "Selecione uma série e uma turma");
        }else{
            String serie = null,turma;
            if(jRB_1.isSelected()){
                serie=jRB_1.getText();
            }else if(jRB_2.isSelected()){
                serie=jRB_2.getText();
            }else if(jRB_3.isSelected()){
                serie=jRB_3.getText();
            }
            turma=jCB_descricao1.getSelectedItem().toString();
            try {
                listaP= hamet.BuscaHAporTurma(serie,turma);
            } catch (SQLException ex) {
                Logger.getLogger(FormHorasAula.class.getName()).log(Level.SEVERE, null, ex);
            }
            jScrollPane2.setVisible(true);
            jTTabela_HA2.setVisible(true);
            jl_Totalha.setVisible(true);
            jTF_totalHA.setVisible(true);
            mostraPesquisa2(listaP);
            int quantha=hamet.BuscaQuantHA(serie,turma);
            jTF_totalHA.setText(String.valueOf(quantha));
        }
    }//GEN-LAST:event_jLabel4MouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FormHorasAula.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new FormHorasAula().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox CB_Professor;
    private javax.swing.JTextField JTF_Pesquisar2;
    private javax.swing.JRadioButton RB_Materia;
    private javax.swing.JRadioButton RB_Professor;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.ButtonGroup buttonGroup3;
    private javax.swing.JComboBox jCB_ano;
    private javax.swing.JComboBox jCB_descricao;
    private javax.swing.JComboBox jCB_descricao1;
    private javax.swing.JComboBox jCB_disciplina;
    private javax.swing.JDesktopPane jDesktopPane1;
    private javax.swing.JLabel jL_adicionar;
    private javax.swing.JLabel jL_deletar;
    private javax.swing.JLabel jL_editar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JRadioButton jRB_1;
    private javax.swing.JRadioButton jRB_2;
    private javax.swing.JRadioButton jRB_3;
    private javax.swing.JRadioButton jRB_adicionar;
    private javax.swing.JRadioButton jRB_deletar;
    private javax.swing.JRadioButton jRB_visualizar;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTextField jTF_horaaula;
    private javax.swing.JTextField jTF_totalHA;
    private javax.swing.JTable jTTabela_HA2;
    private javax.swing.JTable jTTable_hora_aula;
    private javax.swing.JLabel jl_Totalha;
    private javax.swing.JLabel jl_ano;
    private javax.swing.JLabel jl_descricao;
    private javax.swing.JLabel jl_descricao1;
    private javax.swing.JLabel jl_disciplina;
    private javax.swing.JLabel jl_eixo;
    private javax.swing.JLabel jl_eixo1;
    private javax.swing.JLabel jl_eixo2;
    private javax.swing.JLabel jl_eixo3;
    private javax.swing.JLabel jl_eixo4;
    private javax.swing.JTextField jl_hora_aulas;
    private javax.swing.JLabel jl_horaaula;
    private javax.swing.JTextField jl_materia;
    private javax.swing.JLabel jl_nome;
    private javax.swing.JTextField jl_prof;
    private javax.swing.JTextField jl_serie;
    private javax.swing.JLabel jl_serie1;
    private javax.swing.JTextField jl_turma;
    private javax.swing.JLabel jlpesquisa;
    // End of variables declaration//GEN-END:variables
 private void ChamaEscolha(String escolha) {
         if("<html>Adicionar<br><br>Alterar".equals(escolha)){
    jLabel2.setVisible(true); 
     jl_ano.setVisible(true); 
     jCB_ano.setVisible(true); 
     jl_descricao.setVisible(true); 
     jCB_descricao.setVisible(true); 
       
        }else if("Deletar".equals(escolha)){
          JTF_Pesquisar2.setVisible(true);
        jlpesquisa.setVisible(true);
        RB_Materia.setVisible(true);
        RB_Professor.setVisible(true);
        id=0;
        jTTable_hora_aula.setVisible(true);
        jl_serie.setVisible(true);
        jl_turma.setVisible(true);
        jl_prof.setVisible(true);
        jl_materia.setVisible(true);
        jl_hora_aulas.setVisible(true);
        jl_eixo.setVisible(true);
        jl_eixo1.setVisible(true);
        jl_eixo2.setVisible(true);
        jl_eixo3.setVisible(true);
        jl_eixo4.setVisible(true);
        jL_deletar.setVisible(true);
        jScrollPane1.setVisible(true);
        RB_Professor.setSelected(true);
        }else if("Visualizar".equals(escolha)){
        jl_serie1.setVisible(true);
        jRB_1.setVisible(true);
        jRB_2.setVisible(true);
        jRB_3.setVisible(true);
        jl_descricao1.setVisible(true);
        jCB_descricao1.setVisible(true);
        jLabel4.setVisible(true);
        
        }
    }
 
    private void DesabilitaADDALT() {
     jLabel2.setVisible(false); 
     jl_ano.setVisible(false); 
     jCB_ano.setVisible(false); 
     jl_descricao.setVisible(false); 
     jCB_descricao.setVisible(false); 
     jLabel1.setVisible(false);   
     jl_nome.setVisible(false);
     CB_Professor.setVisible(false);
     jl_disciplina.setVisible(false);
     jCB_disciplina.setVisible(false);
     jLabel3.setVisible(false);
     jl_horaaula.setVisible(false);
     jL_adicionar.setVisible(false);
     jL_editar.setVisible(false);
     jTF_horaaula.setVisible(false);
       
    }

    private void DesabilitaVISDEL() {
        JTF_Pesquisar2.setVisible(false);
        jlpesquisa.setVisible(false);
        RB_Materia.setVisible(false);
        RB_Professor.setVisible(false);
        id=0;
        jTTable_hora_aula.setVisible(false);
        jl_serie.setVisible(false);
        jl_turma.setVisible(false);
        jl_prof.setVisible(false);
        jl_materia.setVisible(false);
        jl_hora_aulas.setVisible(false);
        jl_eixo.setVisible(false);
        jl_eixo1.setVisible(false);
        jl_eixo2.setVisible(false);
        jl_eixo3.setVisible(false);
        jl_eixo4.setVisible(false);
        jL_deletar.setVisible(false );
        jScrollPane1.setVisible(false);
        limpaDados();
        JTF_Pesquisar2.setText("");
    }

    private void InicializaDadosADDALT() throws SQLException {
        String[] ano=seriemet.BuscarAno();
       
        jCB_ano.setModel(new javax.swing.DefaultComboBoxModel(ano));
        String nome= jCB_ano.getSelectedItem().toString();
        listaS=seriemet.Buscar(nome);
        String[] descrição = new String[listaS.size()];
        for(int i = 0;listaS.size()>i;i++){
        serie = listaS.get(i);
        descrição[i] = serie.getTurma(); 
        }
        jCB_descricao.setModel(new javax.swing.DefaultComboBoxModel(descrição));
    }

  private void JTTabelaLinhaSelecionada(JTable tabela) {
        if (jTTable_hora_aula.getSelectedRow() >= 0) {
            jl_hora_aulas.setText(String.valueOf(HA.get(tabela.getSelectedRow()).getHoras_aula()));
            jl_materia.setText((HA.get(tabela.getSelectedRow()).getMateria()));
            jl_prof.setText((HA.get(tabela.getSelectedRow()).getProfessor()));
            jl_serie.setText((HA.get(tabela.getSelectedRow()).getSerie()));
            jl_turma.setText((HA.get(tabela.getSelectedRow()).getTurma()));  
            id=HA.get(tabela.getSelectedRow()).getId();
        } else {
           limpaDados();
        }
    }

  private void JTTabelaLinhaSelecionada2(JTable tabela) {
        
    }
    private void BuscaDadosTabela() throws SQLException {
         HorasAulaMet dao = new HorasAulaMet();
        HA = dao.BuscarPorProf(JTF_Pesquisar2.getText()+"%");
        mostraPesquisa(HA);
    }

    private void mostraPesquisa(List<HorasAula> HA) {
       while (tmHA.getRowCount() > 0) {
            tmHA.removeRow(0);
        }
        if (HA.isEmpty()) {
        } else {
            String[] linha = new String[]{null, null, null, null, null};
            for (int i = 0; i < HA.size(); i++) {
                tmHA.addRow(linha);
                tmHA.setValueAt(HA.get(i).getSerie(), i, 0);
                tmHA.setValueAt(HA.get(i).getTurma(), i, 1);
                tmHA.setValueAt(HA.get(i).getProfessor(), i, 2);
                tmHA.setValueAt(HA.get(i).getMateria(), i, 3);
                tmHA.setValueAt(HA.get(i).getHoras_aula(), i, 4);
                
            }
        }
    }

    private void limpaDados() {
        jl_hora_aulas.setText("");
        jl_materia.setText("");
        jl_prof.setText("");
        jl_serie.setText("");
        jl_turma.setText("");
      
    }

    private void PesquisarPorMateria() throws SQLException {
        HorasAulaMet dao = new HorasAulaMet();
        HA = dao.BuscarPorMat(JTF_Pesquisar2.getText()+"%");
        mostraPesquisa(HA);
    }

    private boolean Verificasehaseie() {
        try {
            listaS=seriemet.Buscar("%");
        } catch (SQLException ex) {
            Logger.getLogger(FormHorasAula.class.getName()).log(Level.SEVERE, null, ex);
        }
        if(listaS.isEmpty()){
            return false;
        }else{
            return true;
        }
    }

    private boolean VerificaseHA() {
        try {
            HA=hamet.BuscarPorProf("%");
            
        } catch (SQLException ex) {
            Logger.getLogger(FormHorasAula.class.getName()).log(Level.SEVERE, null, ex);
        }
        if(HA.isEmpty()){
            return false;
        }else{
            return true;
        }
    }

    private void DesabilitaVis() {
        jl_serie1.setVisible(false);
        jRB_1.setVisible(false);
        jRB_2.setVisible(false);
        jRB_3.setVisible(false);
        jl_descricao1.setVisible(false);
        jCB_descricao1.setVisible(false);
        jLabel4.setVisible(false);
        jScrollPane2.setVisible(false);
        jTTabela_HA2.setVisible(false);
        jl_Totalha.setVisible(false);
        jTF_totalHA.setVisible(false);
    }

    private void mostraPesquisa2(List<Professor> p) {
        while (tmHA2.getRowCount() > 0) {
            tmHA2.removeRow(0);
        }
        if (p.isEmpty()) {
        } else {
            String[] linha = new String[]{null, null, null, null, null};
            for (int i = 0; i < p.size(); i++) {
                tmHA2.addRow(linha);
                tmHA2.setValueAt(p.get(i).getNome(), i, 0);
                tmHA2.setValueAt(p.get(i).getDisciplinas(), i, 1);
                tmHA2.setValueAt(p.get(i).getAulas(), i, 2);
                
                
            }
        }
    }
}
